

// 工具类
var RaUtil = {
    // 克隆对象
    cloneObject: function(objectToBeCloned){
        // Basis.
		if (!(objectToBeCloned instanceof Object)) {
			return objectToBeCloned;
		}
		let objectClone = null;
		// Filter out special objects.
		let Constructor = objectToBeCloned.constructor;
		switch (Constructor) {
			// Implement other special objects here.
			case RegExp:
				objectClone = new Constructor(objectToBeCloned);
				break;
			case Date:
				objectClone = new Constructor(objectToBeCloned.getTime());
				break;
			default:
				objectClone = new Constructor();
		}
		// Clone each property.
		for (const prop of Object.keys(objectToBeCloned)) {
			objectClone[prop] = RaUtil.cloneObject(objectToBeCloned[prop]);
		}

		return objectClone;
    }
};

module.exports = RaUtil;
